

package com.hd2tecnologia.banco;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Dulcyelliton Silva
 */
public class AcessoBanco {

    Connection con;

    public Connection conectar(){
        try {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost/dscontrol?user=root&password=root");
        } catch (SQLException ex) {
            Logger.getLogger(AcessoBanco.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(AcessoBanco.class.getName()).log(Level.SEVERE, null, ex);
        }
        return con;
    }

    public void desconectar(){
        try {
            con.close();
        } catch (SQLException ex) {
            Logger.getLogger(AcessoBanco.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
